package com.example.springsecurity.handler;

import com.example.springsecurity.pojo.R;
import com.example.springsecurity.util.ResponseUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: anwenbiao
 * @Description: TODO
 * @DateTime: 2023/2/5 11:56
 */
@Component
public class failHandler implements AuthenticationFailureHandler {
    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
        ResponseUtils.sendWirte(response, R.faild("认证失败"));
    }
}
